home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 4.1 KB | 154 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: ODFLib.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993-1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #ifdef FW_BUILD_MAC
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #include <CodeFragments.h>
- #include <Events.h>
- //z#include "SLExcept.h"
-
- #endif
-
- #if defined(SYMANTEC_CPLUS) && defined(FW_BUILD_MAC)
- #define ODF_COLLEC_CFMINIT PartCFMInit
- #endif
-
- //========================================================================================
- // Prototypes
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- extern "C" pascal OSErr ODF_LIBRARY_CFMINIT (CFragInitBlockPtr initBlkPtr);
- extern "C" pascal void ODF_LIBRARY_CFMTERM (void);
-
- #if GENERATINGPOWERPC
-
- #ifdef __MWERKS__
- # if __MWERKS__ < 0x0800
- extern "C" void __sinit();
- extern "C" void __destroy_global_chain(void);
- # else
- extern "C" short __initialize();
- extern "C" void __terminate(void);
- # endif
- #elif defined __MRC__
- extern "C" __init_lib(CFragInitBlockPtr initBlkPtr);
- #endif
-
- #endif // GENERATINGPOWERPC
-
- #endif // FW_BUILD_MAC
-
- //========================================================================================
- // Global Variable
- //========================================================================================
- // FW_gInstance is initialized in DLLMain for Windows
- // FW_gInstance is defined in FWCFMRes.cpp for the Mac
- #ifdef FW_BUILD_WIN
- FW_Instance FW_gInstance = NULL;
- #endif
-
- //========================================================================================
- // Initialization methods
- //========================================================================================
-
- #ifdef FW_BUILD_WIN32
- //----------------------------------------------------------------------------------------
- // DllMain
- //----------------------------------------------------------------------------------------
- extern "C" BOOL WINAPI DllMain(HINSTANCE hDLL,
- DWORD dwReason,
- LPVOID /* lpReserved */)
- {
- if(dwReason == DLL_PROCESS_ATTACH)
- {
- // Save instance handle for future use
- FW_gInstance = hDLL;
- }
-
- return TRUE;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // ODF_LIBRARY_CFMINIT (Has to be upper case because of the 68K Linker)
- //----------------------------------------------------------------------------------------
-
- extern "C" pascal OSErr ODF_LIBRARY_CFMINIT(CFragInitBlockPtr initBlkPtr)
- {
-
- #ifdef FW_DEBUG
- #define FW_COMMAND 0x37
-
- KeyMap theKeyMap;
- ::GetKeys(theKeyMap);
- const unsigned char *theKeys = (const unsigned char *) theKeyMap;
- if ((theKeys[FW_COMMAND >> 3] >> (FW_COMMAND & 7)) & 1)
- ::DebugStr("\p ODF_LIBRARY_CFMINIT");
- #endif
-
- // Shared libraries don't get there static objects initialized correctly without
- // calling __initialize or __CPlusInit for MetroWerks or MrC respectively.
-
- #ifdef __MWERKS__
- #if __MWERKS__ < 0x0800
- __sinit();
- #else
- __initialize();
- #endif
- #elif defined __MRC__
- __init_lib(initBlkPtr);
- #endif
-
- #ifndef FW_NATIVE_EXCEPTIONS
- // FW_gInStaticInit is initialized to a special magic number before static initialization (at linktime)
- // within SLExcept.cpp. Here we clear it to zero. This allows FWExcLib to
- // understand when static objects are being constructed.
- extern long FW_gInStaticInit;
- FW_gInStaticInit = 0L;
- #endif
-
- return FW_CAcquireCFMResourceAccess::PrivInitLibraryResources(initBlkPtr);
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // ODFCFMTERM
- //----------------------------------------------------------------------------------------
-
- extern "C" pascal void ODF_LIBRARY_CFMTERM(void)
- {
- FW_CAcquireCFMResourceAccess::PrivCloseLibraryResources();
-
- #if GENERATINGPOWERPC
- # ifdef __MWERKS__
- # if __MWERKS__ < 0x0800
- __destroy_global_chain();
- # else
- __terminate();
- # endif
- # endif
- #endif
- }
-
- #endif
-
-